#include "Scene/Entity.h"
#include "Entity.h"

namespace CC {

	Entity::Entity(Scene* scene)
		: m_Scene(scene), m_parent(nullptr)
	{
        for(int i = 0; i < ComponentType_MAX; i++){
            m_components.push_back(NULL);
        }
	}

    Entity::~Entity()
    {
        // CC_CORE_INFO("Entity::~Entity()========\n");
        // auto &tag = GetComponent<TagComponent>();
        // CC_CORE_INFO("Entity::~Entity()=%s\n", tag.Tag.c_str());

        /*std::vector<Entity *>::iterator it = m_childs.begin();
        for (it; it != m_childs.end(); it++)
        {
            delete *it;
        }*/
        for(int i = 0; i < ComponentType_MAX; i++){
            if(m_components[i]){
                delete m_components[i];
                m_components[i] = NULL;
            }
        }

        RemoveAllChild();
        m_childs.clear();
        m_userdatas.clear();
    }
    void Entity::SetUserData(const std::string & id, const std::string & data)
    {
        m_userdatas[id] = data;
    }
    const std::string Entity::GetUserData(const std::string & id)
    {
        return m_userdatas[id];
    }
}